package com.zj.fx.service.rpa;

import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.mapper.rpa.RpaTaskDtlMapper;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.model.rpa.RpaTaskDtl;
import com.zj.fx.model.rpa.RpaTaskDtlExample;
import com.zj.fx.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * rpa任务执行明细 RpaTaskDtlService
 *
 * @author SQL_自动生成
 * @Title: RpaTaskDtlService.java 
 * @Package com.zj.fx.service 
 * @email ${email}
 * @date 2023-11-18 09:44:17  
 **/
@Service
public class RpaTaskDtlService implements BaseService<RpaTaskDtl, RpaTaskDtlExample> {
    @Autowired
    private RpaTaskDtlMapper rpaTaskDtlMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<RpaTaskDtl> list(Tablepar tablepar, RpaTaskDtl rpaTaskDtl) {
        RpaTaskDtlExample testExample = new RpaTaskDtlExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(rpaTaskDtl);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<RpaTaskDtl> list = rpaTaskDtlMapper.selectByExample(testExample);
        PageInfo<RpaTaskDtl> pageInfo = new PageInfo<RpaTaskDtl>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        RpaTaskDtlExample example = new RpaTaskDtlExample();
        example.createCriteria().andIdIn(lista);
        return rpaTaskDtlMapper.deleteByExample(example);


    }


    @Override
    public RpaTaskDtl selectByPrimaryKey(String id) {

        return rpaTaskDtlMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(RpaTaskDtl record) {
        return rpaTaskDtlMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(RpaTaskDtl record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return rpaTaskDtlMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(RpaTaskDtl record, RpaTaskDtlExample example) {

        return rpaTaskDtlMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(RpaTaskDtl record, RpaTaskDtlExample example) {

        return rpaTaskDtlMapper.updateByExample(record, example);
    }

    @Override
    public List<RpaTaskDtl> selectByExample(RpaTaskDtlExample example) {

        return rpaTaskDtlMapper.selectByExample(example);
    }


    @Override
    public long countByExample(RpaTaskDtlExample example) {

        return rpaTaskDtlMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(RpaTaskDtlExample example) {

        return rpaTaskDtlMapper.deleteByExample(example);
    }


}
